package fan.project3_pksystem.Config;

import fan.project3_pksystem.Game.GameApi;
import fan.project3_pksystem.WebSocket.FindPlayerApi;
import fan.project3_pksystem.WebSocket.TestApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor;

@Configuration
@EnableWebSocket
public class WebSocketConf implements WebSocketConfigurer {
    @Autowired
    private TestApi test1;
    @Autowired
    private FindPlayerApi findPlayerApi;
    @Autowired
    private GameApi gameApi;

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(test1, "/test1");

        registry.addHandler(findPlayerApi, "/findPlayer").addInterceptors(new HttpSessionHandshakeInterceptor());
        registry.addHandler(gameApi, "/game1").addInterceptors(new HttpSessionHandshakeInterceptor());

    }
}
